/*
 * CacheTask.hpp
 *
 *  Created on: 09.12.2012
 *      Author: zheka
 */

#ifndef CACHETASK_HPP_
#define CACHETASK_HPP_

#include "io/Task.hpp"
#include "http/HttpRequest.hpp"
#include "CacheEntry.hpp"
#include "http/HttpResponseParser.hpp"
class CacheTask: public Task {
private:
enum {
	STATE_READ_HEADER, STATE_READ_DATA, STATE_FINISHED
};
	std::string requestData;
	CacheEntry * cacheEntry;
	size_t written;
	HttpResponseParser parser;
int state;
size_t contentLength;
size_t readCount;
std::string data;
std::string query;
std::string lineBuffer;
int chunkSize;
bool readChunk;
bool chuncked;
public:
	CacheTask(CacheEntry * cacheEntry, const HttpRequest & request);
	virtual void onInit(Context & context);
	virtual void onRead(Context & context);
	virtual void onWrite(Context & context);
	virtual std::string toString();
};

#endif /* CACHETASK_HPP_ */
